package com.zkh.myutils.scheduled;

import java.util.Objects;

import com.zkh.myutils.json.JSONObject;
import com.zkh.myutils.scheduled.cron.CronBean;
import com.zkh.myutils.utils.StringUtils;

/**
 * 定时任务配置
 * @author zkh
 *
 */
public class ScheduledTaskConfig {
	//作业编码
	private String jobEcd;
	//作业描述
	private String jobDesc;
	//cron表达式
	private String cronExp;
	//作业Bean
	private String jobBeanName;
	//作业参数
	private String jobParam;
	//cron对象
	private CronBean cronBean;
	
	//任务Bean
	private ScheduledTask scheduledTask;
	//参数
	private JSONObject jobParamJson;
	
	public String getJobEcd() {
		return jobEcd;
	}
	public void setJobEcd(String jobEcd) {
		this.jobEcd = jobEcd;
	}
	public String getJobDesc() {
		return jobDesc;
	}
	public void setJobDesc(String jobDesc) {
		this.jobDesc = jobDesc;
	}
	public String getCronExp() {
		return cronExp;
	}
	public void setCronExp(String cronExp) {
		this.cronExp = cronExp;
	}
	public String getJobBeanName() {
		return jobBeanName;
	}
	public void setJobBeanName(String jobBeanName) {
		this.jobBeanName = jobBeanName;
	}
	public String getJobParam() {
		return jobParam;
	}
	public void setJobParam(String jobParam) {
		//空
		if(StringUtils.isEmpty(jobParam)) {
			jobParam = "{}";
		}
		this.jobParam = jobParam;
		this.jobParamJson = new JSONObject(jobParam);
	}
	public ScheduledTask getScheduledTask() {
		return scheduledTask;
	}
	public void setScheduledTask(ScheduledTask scheduledTask) {
		this.scheduledTask = scheduledTask;
	}
	public CronBean getCronBean() {
		return cronBean;
	}
	public void setCronBean(CronBean cronBean) {
		this.cronBean = cronBean;
	}
	public JSONObject getJobParamJson() {
		return jobParamJson;
	}
	public void setJobParamJson(JSONObject jobParamJson) {
		this.jobParamJson = jobParamJson;
	}
	@Override
	public int hashCode() {
		return Objects.hash(jobEcd);
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ScheduledTaskConfig other = (ScheduledTaskConfig) obj;
		return Objects.equals(jobEcd, other.jobEcd);
	}
	
	@Override
	public String toString() {
		return "ScheduledTaskConfig [jobEcd=" + jobEcd + ", jobDesc=" + jobDesc
				+ ", cronExp=" + cronExp + ", jobBeanName=" + jobBeanName
				+ ", jobParam=" + jobParam + "]";
	}
}
